// video
var videoObj = {
    loadVideo: function (videoThumb, videoUrl, tar) {
        var html = '<!--[if !IE]><!--><video autoplay id="player1" data-site="pcauto" width="100%" height="100%" poster="';
        html += videoThumb + '"><source quality="1" title="超清" src="';
        html += videoUrl[0] + '" type="video/mp4"><source quality="2" title="高清" src="';
        html += videoUrl[1] + '" type="video/mp4"><source quality="3" title="标清" src="';
        html += videoUrl[2] + '" type="video/mp4"></video><!--<![endif]--> <!--[if lte IE 9]> <object id="pcplayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115" height="100%" width="100%"><param name="movie" value="http://online.pcvideo.com.cn/player/pcplayer_3.7.swf" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="menu" value="false" /><param name="wmode" value="opaque" /><param name="flashvars" value="domain=pcauto&flv=';
        html += videoUrl[0] + '&thumb=' + videoThumb + '&controlbar=always&id=19983&pt=1&skin=http://online.pcvideo.com.cn/skin/pc_skin_3.6.swf&loadswf=http://flv.pcauto.com.cn/load/pcauto_load_3.1.swf&pointUrl=http://pcauto.pcvideo.com.cn/interface/video_point_in.jsp?vedio_id=19983&autoplay=true" /><embed name="pcplayer" src="http://online.pcvideo.com.cn/player/pcplayer_3.7.swf" flashvars="domain=pcauto&flv=';
        html += videoUrl[0] + '&thumb=' + videoThumb + '&controlbar=always&id=19983&pt=1&skin=http://online.pcvideo.com.cn/skin/pc_skin_3.6.swf&loadswf=http://flv.pcauto.com.cn/load/pcauto_load_3.1.swf&pointUrl=http://pcauto.pcvideo.com.cn/interface/video_point_in.jsp?vedio_id=19983&autoplay=true" wmode="opaque" type="application/x-shockwave-flash" height="100%" width="100%" allowScriptAccess="always" allowFullScreen="true" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object><![endif]-->';

        tar.siblings('.vmain').show().html(html);

        if ("MediaElementPlayer" in window) {
            // window.MediaElementPlayer=null
            var player1 = new MediaElementPlayer('player1', { //,'next'
                features: ['progress', 'timepreview', 'playpause', 'current', 'duration', 'fullscreen', 'next', 'volume', 'sourcechooser', 'speed', 'logo', 'postroll', 'tips', 'contextmenu'],
                // 移动设隐藏声音按钮
                hideVolumeOnTouchDevices: true,
                //设置加载了多长时间后（ms）显示慢提示
                slowTipTimeinSeeking: 3000,
                // 上次播放时间提示的关闭时间
                prveTimeTipTimeout: 3000,
                // 保存上次播放时间的视频个数
                prevTimeHistoryNum: 20,
                // 是否通过js而不是css设置尺寸
                setDimensions: false,
                timeAndDurationSeparator: "/"
                // ,alwaysShowControls:true
                ,
                controlsTimeoutMouseLeave: 0
                // ,useDefaultControls: true
            });
        }
        // console.log(window)
    },
    setVideo: function (tar) {
        var videoFlv, videoThumb, videoUrl = [];
        videoFlv = tar.attr('mp4') + '';
        videoThumb = tar.find('img').attr('src') || '//www1.pcauto.com.cn/images/blank.gif';
        var str = videoFlv.replace(/(^\s*)/g, "").slice(0, -5);
        for (var j = 3; j > 0; j--) {
            videoUrl.push(str + j + '.mp4');
        }
        videoObj.loadVideo(videoThumb, videoUrl, tar)
    },
    videoEvent: function () {
        $('.video1').click(function () {
            var _this = $(this)
            videoObj.setVideo(_this);
            $(this).hide()
        })
    },
    init: function () {
        this.videoEvent();
    },
}
videoObj.init();
